package com.luke.springcloud.controller;

import com.luke.springcloud.entities.UserInfo;
import com.luke.springcloud.feign.ProviderFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;

/**
 * @Descrtption FeignConsumerController
 * @Author luke
 * @Date 2020/5/12
 **/
@Slf4j
@RequestMapping("/consumer")
@RestController
public class FeignConsumerController {

    @Resource
    private ProviderFeignClient providerFeignClient;

    @GetMapping("/echo/{id}")
    public UserInfo consumerEcho(@PathVariable("id") Long id){
        log.info("consumerEcho,id:{}",id);
        return providerFeignClient.echo(id);
    }

    @GetMapping("/query/{id}")
    public UserInfo consumerQueryUserInfo(@PathVariable("id") Long id){
        log.info("consumerQueryUserInfo,id:{}",id);
        UserInfo userInfo = new UserInfo();
        userInfo.setId(id);
        return providerFeignClient.queryUserInfo(userInfo);
    }

}
